﻿Imports System.IO

Public Class FormMenuUsuarios

    Private Sub FormNuevoBorrarModificarProdServ_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub bt_añadir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_añadir.Click
        Try
            Me.Hide()
            FormAñadirusuario.Show()
        Catch ex As Exception
            MsgBox(Err.Description & " Error número:" & Err.Number)
        End Try
    End Sub

    Private Sub bt_modificar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_modificar.Click
        Try
            Me.Hide()
            FormModificarUsuario.Show()
        Catch ex As Exception
            MsgBox(Err.Description & " Error número:" & Err.Number)
        End Try
    End Sub

    Private Sub bt_borrar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_borrar.Click
        Try
            If lb_usuarios.SelectedIndex = -1 Then
                MsgBox("No se ha seleccionado un usuario, no se puede borrar")
            Else
                Me.Hide()
                FormBorrarUsuario.Show()
            End If
        Catch ex As Exception
            MsgBox(Err.Description & " Error número:" & Err.Number)
        End Try
    End Sub

    Private Sub bt_Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_Cancel.Click
        Try
            Me.Hide()
        Catch ex As Exception
            MsgBox(Err.Description & " Error número:" & Err.Number)
        End Try
    End Sub

    Private Sub bt_mostrar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_mostrar.Click
        Try
            lb_usuarios.Items.Clear()
            Dim a As New StreamReader("C:\eleemeTPV\users\FichUsuarios.txt")
            Dim nombre As String
            Dim cod As String
            Do
                nombre = a.ReadLine
                cod = a.ReadLine
                lb_usuarios.Items.Add(nombre)
            Loop Until nombre Is Nothing Or nombre = ""


            'FileOpen(1, "C:\eleemeTPV\users\FichUsuarios.txt", OpenMode.Input)
            'While Not EOF(1)
            '    Input(1, reg.codigo)
            '    Input(1, reg.nombre)
            '    lb_usuarios.Items.Add(reg.nombre)
            'End While
            'While Not EOF(1)
            'Input(1, reg.codigo)
            'Input(1, reg.nombre)
            'lb_usuarios.Items.Add(reg.codigo & " " & reg.nombre)
            'End While
            'FileClose()
        Catch ex As Exception
            'saveerrror.dfdf(EX.TOSTRING)
        End Try
    End Sub

End Class